# 抽象方法
# from abc import ABCMeta, abstractmethod
#
#
# class Animal(metaclass=ABCMeta):
#
#     @abstractmethod
#     def eat(self):
#         pass
#
#     @abstractmethod
#     def run(seft):
#         pass
#
#
# class Dog(Animal):
#
#     def eat(self):
#         print("Dog is eating")
#
#
# dog = Dog()

# from abc import ABCMeta, abstractmethod
#
#
# # 定义抽象类时，使用metaclass=ABCMeta
# class Animal(metaclass=ABCMeta):
#
#     @abstractmethod
#     def eat(self):
#         pass
#
#
# class Dog(Animal):
#     pass
#
#
# dog = Dog()

# from abc import ABCMeta, abstractmethod
#
#
# # 定义抽象类时，使用metaclass=ABCMeta
# class Animal(metaclass=ABCMeta):
#
#     @abstractmethod
#     def eat(self):
#         pass
#
#
# class Dog(Animal):
#     def eat(self):
#         print("dog is eating")
#
#
# dog = Dog()
# dog.eat()


# 多态
# 定义animal类
from abc import ABCMeta, abstractmethod


# 定义抽象类时，使用metaclass=ABCMeta
class Animal(metaclass=ABCMeta):

    @abstractmethod
    def eat(self):
        pass

    @abstractmethod
    def run(seft):
        pass

    def activity(self):
        self.eat()
        self.run()


class Dog(Animal):
    def eat(self):
        print("Dog is eating")

    def run(self):
        print("dog is running")


class Cat(Animal):
    def eat(self):
        print("cat is eating")

    def run(self):
        print("cat is running")


# 不同的子类对象，调用父类的activity方法，产生不同的执行结果
dog = Dog()
cat = Cat()
dog.activity()
cat.activity()
